import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

/* Layout */
// import Layout from "@/layout/index.vue";

const constantRoutes = [
  {
    path: "/",
    component: () => import("@/views/login.vue"),
    name: "login",
    meta: {
      title: "登录",
      icon: "dashboard",
      affix: true,
      keepAlive: false,
    },
  },
  {
    path: "/realtime",
    component: () => import("@/views/gis/realtime.vue"),
    name: "realtime",
    meta: {
      title: "GIS监控",
      icon: "dashboard",
      affix: true,
      keepAlive: false,
    },
  },
  {
    path: "/historyTrack",
    component: () => import("@/views/gis/historyTrack.vue"),
    name: "historyTrack",
    meta: {
      title: "轨迹回放",
      icon: "dashboard",
      affix: true,
      keepAlive: false,
    },
  },
  {
    path: "/indicatorMonitoring",
    component: () => import("@/views/gis/indicatorMonitoring.vue"),
    name: "indicatorMonitoring",
    meta: {
      title: "指标监控",
      icon: "dashboard",
      affix: true,
      keepAlive: false,
    },
  },

];

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch((err) => err);
};
// replace
VueRouter.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch((err) => err);
};

export default new VueRouter({
  mode: "history", // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes,
});


